<?php


class Queue {

	/**
	 * 队列
	 * @var
	 */
	private $queue;

	/**
	 * 队列长度
	 * @var
	 */
	private $size;

	public function __construct() {
		$this->queue = array();
		$this->size  = 0;
	}

	//获取队列
	public function getQueue() {
		return $this->queue;
	}

	//获取队列的长度
	public function getSize() {
		return $this->size;
	}

	//获取队头元素
	public function getFront() {
		if(!$this->isEmpty()){
			return $this->size[0];
		}
		return false;
	}

	//入队列
	public function enqueue($data) {
		$this->queue[$this->size++] = $data;
		return $this;
	}

	//出队列
	public function dequeue() {
		if(!$this->isEmpty()){
			$this->size--;
			return array_splice($this->queue,0,1);
		}
		return false;
	}

	//检测队列是否为空
	public function isEmpty() {
		return 0 === $this->size;
	}
}